<?php
header("Pragma: public");
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename=otchet.xls');
header("Content-Transfer-Encoding: binary"); 
?>
<h2>Количество по областям</h2>
<table border=1>
<tr>
<th>Область</th>
<th>Количество</th>
</tr>
<?php 
	foreach ($allregions as $region):
	echo '<tr>';
	echo '<td>';	
	echo $region['Region']['name'];
	echo '</td>';
	echo '<td>';
	echo $region['count'];
	echo '</td>';	
	echo '</tr>';	
	endforeach;

?>
</table>
<?php //debug ($allprofessions);

?>
<h2>Количество абитуриентов по областям по специальностям</h2>
<table border=1>
<?php
foreach ($allprofessions as $profession):
	echo '<tr>';
	echo '<td colspan=2>';
	echo '<b>'.$facultets[$profession['Profession']['facultet_id']].' ';
	echo $profession['Profession']['name'].'</b>';
	echo '</td>';
	echo '</tr>';
	
	$regions = $profession['Profession']['regions'];
	foreach ($regions as $region):
	echo '<tr>';
	echo '<td>';
	echo $region['Region']['name'];
	echo '</td>';	
	echo '<td>';
	echo  $region['count'];
	echo '</td>';	
	echo '</tr>';	
	endforeach;
endforeach;
?>
</table>